package com.ash.vm;

import java.util.ArrayList;
import java.util.List;

/**
 * vm args : -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:/
 */
public class HeapOOM {

    public static void main(String[] args) {
        List<OOMObject> list = new ArrayList<>();
        while (true) {
            list.add(new OOMObject());
        }
        //Exception in thread "main" java.lang.OutOfMemoryError
    }

    private static class OOMObject {

    }
}
